import { defineStore } from 'pinia'
import { getToken,setToken,removeToken } from '@/utils/auth'
import { ref } from 'vue'

export const useUserStore = defineStore('user', ()=>{
    const id = ref('')
    const name = ref('')
    const token = ref('')

    //登录
    async function login(userName,password){
        if (userName == 'admin' && password == '9999') {
            setToken('admin')
            id.value = 'admin'
            name.value = 'admin'
            token.value = 'admin'
            return true
        }else{
            return false
        }
    }

    return { id, name, login }
})